#include "AT24C02.h"
#include "I2C.h"

#define AT24C02_ADDR 0xA0
void AT24C02_WriteByte(unsigned char WordAddr,Data)
{
	I2C_Start();
	I2C_SendByte(AT24C02_ADDR);
	I2C_ReceiveAck();
	I2C_SendByte(WordAddr);
	I2C_ReceiveAck();
	I2C_SendByte(Data);
	I2C_ReceiveAck();
	I2C_Stop();
}

unsigned char AT24C02_ReadByte(unsigned char WordAddr)
{
	unsigned char Data;
	I2C_Start();
	I2C_SendByte(AT24C02_ADDR);
	I2C_ReceiveAck();
	I2C_SendByte(WordAddr);
	I2C_ReceiveAck();
	I2C_Start();
	I2C_SendByte(AT24C02_ADDR|0x01);
	I2C_ReceiveAck();
	Data = I2C_ReceByte();
	I2C_SendAck(1);
	I2C_Stop();
	return Data;
}
